package com.company.exception;


public class Account {
    public double balance;

    public Account(int balance){
        this.balance = balance;
    }
    /** 获取余额 **/
    public double getBalance() {
        return balance;
    }

    /** 存钱 **/
    public double deposite(double money){
        balance += money;
        return balance;
    }

    /** 取钱**/
    public void withdraw(double number) throws OverdraftException {
        balance -= number;
        if (balance < 0)
            throw new OverdraftException("透支:", -balance);
    }

    public static void main(String[] args) {
        Account bank = new Account(100);
        try{
            bank.withdraw(200);
        }catch (OverdraftException e){
            System.out.println("异常的具体原因: " + e.getMessage());
            e.printStackTrace();
        }
    }
    }
